package menu

import (
	"d-serv-go/server/core/bean"
	"d-serv-go/server/core/consts"
	"d-serv-go/server/core/db"
)

type menuMgr struct {

}

func NewMenuMgr() *menuMgr{
	return &menuMgr{}
}

func (m *menuMgr) MenuToCache(userCode string) []*bean.Bean {
	menuTree := make([]*bean.Bean, 0)

	//从系统配置中获取 实现类  eg,PT_SY_COMM_MENU_USER,com.bonc.pt.util.PtMenuFilter
	//PT_SY_COMM_MENU_USER是用户菜单字典，com.bonc.pt.util.PtMenuFilter是菜单的过滤实现类
	//String extClass = Context.getSyConf("SY_MENU_FLITER", "");
	//
	//if (StringUtils.isNotEmpty(extClass)) { //配置了扩展类  字典,扩展类
	//	String[] configArr = extClass.split(",");
	//
	//	menuTree = DictMgr.getTreeList(configArr[0], 0);
	//
	//	MenuFilter menuFilter = null;
	//	try {
	//		menuFilter = (MenuFilter) Lang.loadClass(configArr[1]).newInstance();
	//	} catch (Exception e) {
	//		log.error(e.getMessage(), e);
	//	}
	//
	//	menuTree = menuFilter.filterMenu(menuTree);
	//} else {
	// dictId, pId, layer, showPid
		menuTree = db.DictMgr.GetTreeList(consts.DICT_SERV_MENU_USER, "", 0, false);
	//}

	db.UserMgr.SetCacheMenuList(userCode, menuTree);
	return menuTree;
}